import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";

export const usersApi = createApi({
  reducerPath: "usersApi",
  baseQuery: fetchBaseQuery({
    baseUrl: "http://jsonplaceholder.typicode.com/users",
  }),
  endpoints: (builder) => ({
    getUser: builder.query({
      query: (name) => `?name=${name}`
    }),
  }),
});

export const { useLazyGetUserQuery, useGetUserQuery } = usersApi;
